#encoding=utf-8
import requests

class MyProxyIpTest(object):

	def __init__(self):
		self.session=requests.session();
		self.headers={"User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"}

	def testProxyIp(self, ip, port):
		print "{0}:{1}".format(ip, port)
		http_proxy= "http://{0}:{1}".format(ip, port)
		https_proxy = "https://{0}:{1}".format(ip, port)
		proxies={"https":https_proxy, "http":http_proxy}
		try:
			r=self.session.get("https://www.baidu.com/", headers=self.headers, verify=False, proxies=proxies, timeout=1)
			if r.status_code == 200:
				return True
			else:
				return False
		except:
			return False


proxyiptest=MyProxyIpTest()
if proxyiptest.testProxyIp("223.202.131.27", "377")==True:
	print "right"